package com.wondersgroup.fjzlpt.console.controller.rest.yljgjfsb;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.util.QuickPrincipalUtils;
import com.wondersgroup.fjzlpt.console.service.inter.yljgjfsb.JfsbxxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 医疗机构设备管理服务
 * <p>
 * <p>
 * Created by sanma on 2017/8/11.
 */
@RestController
@RequestMapping("/yljgsb")
public class YljgsbRestController {

    @Autowired
    private JfsbxxService jfsbxxService;

    /**
     * 分页查询机构机房信息
     * @param request
     * @return
     */
    @RequestMapping("/queryPageJfxx")
    public JSONObject queryPageJfxx(HttpServletRequest request){
        String xzqh = QuickPrincipalUtils.getXzqhdm(request);
        Map map = RequestUtils.GetParameterMap(request);
        map.put("XZQHDM",xzqh);
        return jfsbxxService.queryPageJfxx(map);
    }

    /**
     * 根据ID查询机房设备信息
     * @param request
     * @return
     */
    @RequestMapping("/querySbxxById")
    public JSONArray querySbxxById(HttpServletRequest request){
        Map map = RequestUtils.GetParameterMap(request);
        return jfsbxxService.querySbxxById(map);
    }

    /**
     * 保存机房信息
     * @param request
     * @return
     */
    @RequestMapping("/saveJfxx")
    public JSONObject saveJfxx(HttpServletRequest request){
        Map map = RequestUtils.GetParameterMap(request);
        return jfsbxxService.saveJfxx(map);
    }

    /**
     * 保存设备信息
     * @param request
     * @return
     */
    @RequestMapping("/saveSbxx")
    public JSONObject saveSbxx(HttpServletRequest request){
        Map map = RequestUtils.GetParameterMap(request);
        return jfsbxxService.saveSbxx(map);
    }

    /**
     * 将科室信息导出到Excel
     * @param request
     * @return
     */
    @RequestMapping("/downloadToExcel")
    public void downloadToExcel(HttpServletRequest request, HttpServletResponse response){
        String xzqh = QuickPrincipalUtils.getXzqhdm(request);
        Map map = RequestUtils.GetParameterMap(request);
        map.put("XZQHDM",xzqh);
        jfsbxxService.downloadToExcel(map, request, response);
    }
}
